package com.xt.purchasingsystem.controller;


import com.xt.purchasingsystem.dto.SupplierRecommendDto;
import com.xt.purchasingsystem.model.SupplierRecommend;
import com.xt.purchasingsystem.service.SupplierRecommendService;
import com.xt.purchasingsystem.utils.Result;
import com.xt.purchasingsystem.utils.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yhp
 * @since 2020-05-31
 */
@RestController
@RequestMapping("/supplierRecommend")
public class SupplierRecommendController {

    @Autowired
    private SupplierRecommendService supplierRecommendService;

    /**
     * 登记供应商推荐单and详细表
     */
    @PostMapping
    public Result saveSupplierRecommend(@RequestBody SupplierRecommendDto supplierRecommendDto){
        return supplierRecommendService.saveSupplierRecommend(supplierRecommendDto);
    }
    /**
     * 查询供应商推荐单
     */
    @GetMapping("supplierRecommendationReview/{currNo}/{pageSize}")
    public Result supplierRecommendationReview(@PathVariable Integer currNo, @PathVariable Integer pageSize){
        return  supplierRecommendService.supplierRecommendationReview(currNo,pageSize);
    }

    /**
     *供应商推荐单登记审核
     * @param supplierRecommend
     * @return
     */
    @PutMapping("secommendationSheetReview")
    public Result secommendationSheetReview(@RequestBody SupplierRecommend supplierRecommend) {
        boolean flag = supplierRecommendService.saveOrUpdate(supplierRecommend);
        if (flag) {
            return ResultFactory.buildSuccessResult("复核成功");
        } else {
            return ResultFactory.buildFailResult("复核失败");
        }
    }


}

